package nowcode;

public class LeftRotateStringSolution {

    public String LeftRotateString(String str, int n) {
        if (str.length() == 0) {
            return "";
        }
        n = n % str.length();
        if (n == 0) {
            return str;
        }
        char[] chars = str.toCharArray();
        char[] oldChars = str.toCharArray();
        for (int i = 0; i < chars.length; i++) {
            int index = (i + n) % chars.length;

            chars[i] = oldChars[index];
        }
        return new String(chars);
    }

}
